@POST.configure.php

<?php
/**
 *
 * Save gui-based settings for user lib.
 *
 * POST /user/configure/ ... need to document
 *
 *
 * @warning ANYONE can submit and change database & other configurations.
 */

/** @warning injection possible */

$configs = $_POST;

$dir = dirname(__DIR__);
$file = $dir.'/gui-config.json';


$json = json_encode($configs);

if (strlen($json) > 2048) die('2048 is longest allowed json');

file_put_contents($file, $json);